package com.runa.protocol.util;

/**
 * 2024/11/28 14:57
 * zhangYB
 */
public class UnitUtil {




    public static float toKwh(float src, int unit) {
        switch (unit) {
            case 0x02:
                return src / 1000;
            case 0x08:
                return src * 1000;
            case 0x0a:
                return  src * 1000 * 100;
            case 0x01:
                return (float) (src / 1000000000 * 277.8);
            case 0x0b:
                return (float) (src / 1000000 * 277.8);
            case 0x0e:
                return (float) (src / 1000 * 277.8);
            case 0x11:
                return (float) (src * 277.8);
            case 0x13:
                return (float) (src * 100 * 277.8);
            default:
        }
        return src;
    }

    public static float toKw(float src, int unit) {
        switch (unit) {
            case 0x14:
                return src / 1000;
            case 0x1a:
                return src * 1000;
            default:
        }
        return src;
    }

    public static float toM3(float src, int unit) {
        if (unit == 0x29) {
            return src / 1000;
        }
        return src;
    }

    public static float toM3h(float src, int unit) {
        if (unit == 0x32) {
            return src / 1000;
        }
        return src;
    }



}
